﻿<?php

class Application_Form_Noticia extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
		$this->addDecorator('FormElements')
            -> setAttrib('enctype', 'multipart/form-data')
			->addDecorator('Form');

        $hiddenId = new Zend_Form_Element_Hidden("id");
			
		$textTitle = new Zend_Form_Element_Text('titulo');
		$textTitle
			->setDecorators(array('ViewHelper'))
			->addDecorator('Label')
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field fullwidth'))
			->setAttribs(array('placeholder'=>'Escribe el título de la noticia'))
			->setLabel('Título:');
			
		$fileImage = new Zend_Form_Element_File('foto');
		$fileImage
			->addDecorator('Label')
			->addDecorator('Description',array('escape'=>false,'tag'=>'div'))
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field'))
			->setAttribs(array('class'=>'news-photo-input'))
			->setDescription('Recomendamos subir im&aacute;genes en formato <strong>.jpg</strong> de <strong>600 x 400</strong> pixeles.')
			->setLabel('Imagen de Noticia:');
			
		$selectGallery = new Zend_Form_Element_Select('galeria_id');
		$selectGallery
			->addDecorator('Label')
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field fullwidth'))
			->addMultiOption('0','Galería relacionada:')
			->setLabel('Galería:');

        $galeria = new Application_Model_Galeria();
        $galerias = $galeria->getGalerias();

        foreach($galerias as $g){
            $selectGallery->addMultiOption($g["id"], $g["titulo"]);
        }

		$selectVideo = new Zend_Form_Element_Select('video_id');
		$selectVideo
			->addDecorator('Label')
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field fullwidth'))
			->addMultiOption('0','Video relacionado:')
			->setLabel('Video:');

        $video = new Application_Model_Video();
        $videos = $video->getLast20();

        foreach($videos as $v){
            $selectVideo->addMultiOption($v["id"], $v["titulo"]);
        }

        $fileSlider = new Zend_Form_Element_File('foto_slider');
        $fileSlider = new Zend_Form_Element_File('foto_slider');
		$fileSlider
			->addDecorator('Label')
			->addDecorator('Description',array('escape'=>false,'tag'=>'div'))
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field'))
			->setAttribs(array('class'=>'news-slider-input'))
			->setDescription('Recomendamos subir im&aacute;genes en formato <strong>.jpg</strong>.<br />Las dimensiones necesariamente deben ser de <strong>958 x 359</strong> pixeles.')
			->setLabel('Slider Principal:');
			
		$textAreaDescription = new Zend_Form_Element_Textarea('descripcion');
		$textAreaDescription
			->setDecorators(array('ViewHelper'))
			->addDecorator('Label')
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'field fullwidth'))
			->setAttribs(array('placeholder'=>'Describe persona(s) participes, lugar, fecha y hora de la noticia','class'=>'autogrow','rows'=>'1'))
			->setLabel('Descripción:');
			
		$textAreaContent = new Zend_Form_Element_Textarea('texto');
		$textAreaContent
			->setDecorators(array('ViewHelper'))
			->addDecorator('Label')
			->addDecorator('HtmlTag',array('tag'=>'div','class'=>'no-inner-space'))
			->setAttribs(array('class'=>'editor'))
			->setLabel('Contenido:');															

        $submitForm = new Zend_Form_Element_Submit('submit');
		$submitForm
			->setDecorators(array('ViewHelper'))
			->addDecorator('Description',array('escape'=>false,'tag'=>'div','openOnly'=>true,'placement'=>'prepend'))
			->setAttribs(array('class'=>'bt blue'))
			->setDescription('<footer class="pane">')				
			->setLabel('Publicar');
			
        $resetForm = new Zend_Form_Element_Reset('reset');
		$resetForm
			->setDecorators(array('ViewHelper'))
			->addDecorator('Description',array('escape'=>false,'tag'=>'div','closeOnly'=>true))
			->setAttribs(array('class'=>'bt orange'))
			->setDescription('</footer>')				
			->setLabel('Limpiar');			
		
		$this->addElements( array (
            $hiddenId,
			$textTitle,
			$fileImage,
			$selectGallery,
			$selectVideo,
			$fileSlider,
			$textAreaDescription,
			$textAreaContent,
			$submitForm,
			$resetForm
		));		
		
    }

}